--
-- PostgreSQL database dump
--

-- Started on 2008-05-05 01:05:25

SET client_encoding = 'LATIN1';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

--
-- TOC entry 1765 (class 0 OID 0)
-- Dependencies: 5
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres
--

COMMENT ON SCHEMA public IS 'Standard public schema';


--
-- TOC entry 304 (class 2612 OID 65056)
-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: postgres
--

CREATE PROCEDURAL LANGUAGE plpgsql;


SET search_path = public, pg_catalog;

--
-- TOC entry 252 (class 1247 OID 65058)
-- Dependencies: 1309
-- Name: dblink_pkey_results; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE dblink_pkey_results AS (
	"position" integer,
	colname text
);


ALTER TYPE public.dblink_pkey_results OWNER TO postgres;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- TOC entry 1310 (class 1259 OID 65095)
-- Dependencies: 5
-- Name: actions; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE actions (
    action_id character varying(50) NOT NULL,
    action_name character varying(50)
);


ALTER TABLE public.actions OWNER TO postgres;

--
-- TOC entry 1311 (class 1259 OID 65097)
-- Dependencies: 5
-- Name: alteracao_entrada; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE alteracao_entrada (
    id_alteracao_entrada integer NOT NULL,
    id_entrada integer NOT NULL,
    id_user character varying(38) NOT NULL,
    entrada time without time zone,
    almoco time without time zone,
    retorno time without time zone,
    saida time without time zone,
    data date,
    data_alteracao date,
    situacao character(1)
);


ALTER TABLE public.alteracao_entrada OWNER TO postgres;

--
-- TOC entry 1767 (class 0 OID 0)
-- Dependencies: 1311
-- Name: COLUMN alteracao_entrada.data; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN alteracao_entrada.data IS 'Data que estava armazenada na tabela de entrada antes da modificação';


--
-- TOC entry 1312 (class 1259 OID 65099)
-- Dependencies: 5 1311
-- Name: alteracao_entrada_id_alteracao_entrada_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE alteracao_entrada_id_alteracao_entrada_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.alteracao_entrada_id_alteracao_entrada_seq OWNER TO postgres;

--
-- TOC entry 1768 (class 0 OID 0)
-- Dependencies: 1312
-- Name: alteracao_entrada_id_alteracao_entrada_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE alteracao_entrada_id_alteracao_entrada_seq OWNED BY alteracao_entrada.id_alteracao_entrada;


--
-- TOC entry 1313 (class 1259 OID 65109)
-- Dependencies: 5
-- Name: banco_id_banco_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE banco_id_banco_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.banco_id_banco_seq OWNER TO postgres;

--
-- TOC entry 1314 (class 1259 OID 65111)
-- Dependencies: 1679 5
-- Name: banco; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE banco (
    id_banco bigint DEFAULT nextval('banco_id_banco_seq'::regclass) NOT NULL,
    nome character varying(50) NOT NULL,
    agencia character varying(10) NOT NULL,
    endereco character varying(50),
    cidade character varying(20) NOT NULL,
    telefone character varying(15)
);


ALTER TABLE public.banco OWNER TO postgres;

--
-- TOC entry 1315 (class 1259 OID 65114)
-- Dependencies: 5
-- Name: configuracao_id_configuracao_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE configuracao_id_configuracao_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.configuracao_id_configuracao_seq OWNER TO postgres;

--
-- TOC entry 1316 (class 1259 OID 65116)
-- Dependencies: 1680 5
-- Name: configuracao; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE configuracao (
    id_configuracao bigint DEFAULT nextval('configuracao_id_configuracao_seq'::regclass) NOT NULL,
    msg_atrasado character varying(100),
    msg_fora_horario character varying(100),
    msg_afastado character varying(100),
    msg_func_nao_cadastrado character varying(100),
    caminho_pg_dump character varying(100),
    caminho_pg_restore character varying(100),
    tempo_tolerancia integer,
    tempo_mostrar_foto integer,
    e_escola boolean,
    msg_entrada character varying(100),
    msg_almoco character varying(100),
    msg_retorno character varying(100),
    msg_saida character varying(100),
    tempo_considerar_atrasado integer,
    fechar_dia_automaticamente boolean,
    inicio_dia time without time zone,
    fim_dia time without time zone,
    barrar_func_horario_trabalho boolean,
    intervalo_entre_pontos integer,
    barrar_func_entrada boolean,
    barrar_func_almoco boolean,
    barrar_func_retorno boolean,
    barrar_func_saida boolean,
    msg_erro character varying(30)
);

ALTER TABLE public.configuracao OWNER TO postgres;

--
-- TOC entry 1317 (class 1259 OID 65119)
-- Dependencies: 5
-- Name: curso_id_curso_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE curso_id_curso_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.curso_id_curso_seq OWNER TO postgres;

--
-- TOC entry 1318 (class 1259 OID 65121)
-- Dependencies: 1681 5
-- Name: curso; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE curso (
    id_curso bigint DEFAULT nextval('curso_id_curso_seq'::regclass) NOT NULL,
    nome character varying(50) NOT NULL,
    coordenador bigint NOT NULL,
    duracao integer NOT NULL
);


ALTER TABLE public.curso OWNER TO postgres;

--
-- TOC entry 1319 (class 1259 OID 65129)
-- Dependencies: 5
-- Name: digital_id_digital_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE digital_id_digital_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.digital_id_digital_seq OWNER TO postgres;

--
-- TOC entry 1320 (class 1259 OID 65131)
-- Dependencies: 1682 5
-- Name: digital; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE digital (
    id_digital bigint DEFAULT nextval('digital_id_digital_seq'::regclass) NOT NULL,
    dedo integer NOT NULL,
    id_funcionario bigint NOT NULL,
    template bytea NOT NULL,
    master boolean NOT NULL DEFAULT false
);


ALTER TABLE public.digital OWNER TO postgres;

--
-- TOC entry 1321 (class 1259 OID 65137)
-- Dependencies: 5
-- Name: disciplina_id_disciplina_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE disciplina_id_disciplina_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.disciplina_id_disciplina_seq OWNER TO postgres;

--
-- TOC entry 1322 (class 1259 OID 65139)
-- Dependencies: 1683 5
-- Name: disciplina; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE disciplina (
    id_disciplina bigint DEFAULT nextval('disciplina_id_disciplina_seq'::regclass) NOT NULL,
    nome character varying(50) NOT NULL,
    id_curso bigint NOT NULL,
    id_prof bigint NOT NULL,
    periodo integer
);


ALTER TABLE public.disciplina OWNER TO postgres;

--
-- TOC entry 1323 (class 1259 OID 65142)
-- Dependencies: 5
-- Name: empresa_id_empresa_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE empresa_id_empresa_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.empresa_id_empresa_seq OWNER TO postgres;

--
-- TOC entry 1324 (class 1259 OID 65144)
-- Dependencies: 1684 5
-- Name: empresa; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE empresa (
    id_empresa bigint DEFAULT nextval('empresa_id_empresa_seq'::regclass) NOT NULL,
    razao_social character varying(50) NOT NULL,
    nome_fantasia character varying(50) NOT NULL,
    insc_estadual character varying(30),
    cnpj character varying(30),
    logradouro character varying(50),
    bairro character varying(30),
    cidade character varying(30),
    estado character(2),
    cep character varying(15),
    telefone character varying(15) NOT NULL,
    fax character varying(15),
    email character varying(50)
);

ALTER TABLE public.empresa OWNER TO postgres;

--
-- TOC entry 1325 (class 1259 OID 65147)
-- Dependencies: 5
-- Name: entrada_func_id_entrada_func_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE entrada_func_id_entrada_func_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.entrada_func_id_entrada_func_seq OWNER TO postgres;

--
-- TOC entry 1326 (class 1259 OID 65149)
-- Dependencies: 1685 5
-- Name: entrada_func; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE entrada_func (
    id_entrada_func bigint DEFAULT nextval('entrada_func_id_entrada_func_seq'::regclass) NOT NULL,
    situacao character(1) NOT NULL,
    id_func bigint NOT NULL,
    data date NOT NULL,
    entrada time(0) without time zone NOT NULL,
    almoco time(0) without time zone,
    retorno time(0) without time zone,
    saida time(0) without time zone,
    horas_trabalhadas time without time zone,
    horas_deveriam_ser_trabalhadas time without time zone
);


ALTER TABLE public.entrada_func OWNER TO postgres;

--
-- TOC entry 1769 (class 0 OID 0)
-- Dependencies: 1326
-- Name: COLUMN entrada_func.horas_trabalhadas; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN entrada_func.horas_trabalhadas IS 'Campo para armazenar as horas trabalhadas pelos funcionários, pois podem alterar o horário, perdendo as informações do horário dos dias anteriores.';


--
-- TOC entry 1327 (class 1259 OID 65154)
-- Dependencies: 5
-- Name: feriado_id_feriado_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE feriado_id_feriado_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.feriado_id_feriado_seq OWNER TO postgres;

--
-- TOC entry 1328 (class 1259 OID 65156)
-- Dependencies: 1686 5
-- Name: feriado; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE feriado (
    id_feriado bigint DEFAULT nextval('feriado_id_feriado_seq'::regclass) NOT NULL,
    data character varying(5) NOT NULL,
    motivo character varying(50) NOT NULL
);


ALTER TABLE public.feriado OWNER TO postgres;

--
-- TOC entry 1329 (class 1259 OID 65166)
-- Dependencies: 5
-- Name: folha_pagamento_id_folha_pagamento_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE folha_pagamento_id_folha_pagamento_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.folha_pagamento_id_folha_pagamento_seq OWNER TO postgres;

--
-- TOC entry 1330 (class 1259 OID 65168)
-- Dependencies: 1687 5
-- Name: folha_pagamento; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE folha_pagamento (
    id_folha_pagamento bigint DEFAULT nextval('folha_pagamento_id_folha_pagamento_seq'::regclass) NOT NULL,
    id_func bigint NOT NULL,
    data_geracao date NOT NULL,
    data_referencia date NOT NULL,
    total_horas time(0) without time zone NOT NULL,
    valor_liquido money NOT NULL,
    irrf money NOT NULL,
    inss money NOT NULL,
    desconto money,
    adicional money,
    valor_total money NOT NULL
);


ALTER TABLE public.folha_pagamento OWNER TO postgres;

--
-- TOC entry 1331 (class 1259 OID 65171)
-- Dependencies: 5
-- Name: funcionario_id_funcionario_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE funcionario_id_funcionario_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.funcionario_id_funcionario_seq OWNER TO postgres;

--
-- TOC entry 1332 (class 1259 OID 65173)
-- Dependencies: 1688 1689 1690 1691 5
-- Name: funcionario; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE funcionario (
    id_funcionario bigint DEFAULT nextval('funcionario_id_funcionario_seq'::regclass) NOT NULL,
    nome character varying(50) NOT NULL,
    endereco character varying(50) NOT NULL,
    bairro character varying(20) NOT NULL,
    cidade character varying(20) NOT NULL,
    estado character(2) NOT NULL,
    cep character varying(12) NOT NULL,
    fone character varying(15) NOT NULL,
    celular character varying(15),
    email character varying(40),
    cargo character varying(20) NOT NULL,
    setor character varying(20) NOT NULL,
    data_nasc date NOT NULL,
    data_cadastro date,
    data_admissao date NOT NULL,
    data_demissao date,
    estado_civil character varying(15) NOT NULL,
    sexo character(1) NOT NULL,
    num_carteira character varying(15),
    serie_carteira character varying(15),
    cpf character(14) NOT NULL,
    rg character varying(15) NOT NULL,
    e_professor boolean NOT NULL,
    ponto_automatico boolean NOT NULL,
    salario money,
    ativo boolean NOT NULL,
    num_conta character varying(15),
    id_banco bigint,
    id_titulo_prof bigint,
    id_seq_horario_func bigint,
    foto text,
    permite_ponto_codigo boolean DEFAULT false NOT NULL,
    codigo character varying(20),
    barrar_fora_expediente boolean DEFAULT false NOT NULL,
    barrar_fora_horario boolean DEFAULT false NOT NULL
);



ALTER TABLE public.funcionario OWNER TO postgres;

--
-- TOC entry 1333 (class 1259 OID 65182)
-- Dependencies: 5
-- Name: groups; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE groups (
    group_id character varying(36) NOT NULL,
    group_name character varying(50),
    group_description text
);


ALTER TABLE public.groups OWNER TO postgres;

--
-- TOC entry 1334 (class 1259 OID 65187)
-- Dependencies: 5
-- Name: horario_disc_id_horario_disc_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE horario_disc_id_horario_disc_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.horario_disc_id_horario_disc_seq OWNER TO postgres;

--
-- TOC entry 1335 (class 1259 OID 65189)
-- Dependencies: 1692 5
-- Name: horario_disc; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE horario_disc (
    id_horario_disc bigint DEFAULT nextval('horario_disc_id_horario_disc_seq'::regclass) NOT NULL,
    id_disc bigint NOT NULL,
    ano integer NOT NULL,
    semestre integer NOT NULL,
    dia_semana integer NOT NULL,
    inicio time(0) without time zone NOT NULL,
    fim time(0) without time zone NOT NULL
);


ALTER TABLE public.horario_disc OWNER TO postgres;

--
-- TOC entry 1336 (class 1259 OID 65192)
-- Dependencies: 5
-- Name: horario_func_id_horario_func_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE horario_func_id_horario_func_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.horario_func_id_horario_func_seq OWNER TO postgres;

--
-- TOC entry 1337 (class 1259 OID 65194)
-- Dependencies: 1693 5
-- Name: horario_func; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE horario_func (
    id_horario_func bigint DEFAULT nextval('horario_func_id_horario_func_seq'::regclass) NOT NULL,
    tipo character varying(20) NOT NULL,
    dia_semana integer NOT NULL,
    entrada time(10) without time zone NOT NULL,
    almoco time(10) without time zone NOT NULL,
    retorno time(10) without time zone NOT NULL,
    saida time(10) without time zone NOT NULL
);

ALTER TABLE public.horario_func OWNER TO postgres;

--
-- TOC entry 1338 (class 1259 OID 65202)
-- Dependencies: 5
-- Name: log_id_log_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE log_id_log_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.log_id_log_seq OWNER TO postgres;

--
-- TOC entry 1339 (class 1259 OID 65204)
-- Dependencies: 1694 5
-- Name: log; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE log (
    id_log bigint DEFAULT nextval('log_id_log_seq'::regclass) NOT NULL,
    data date NOT NULL,
    hora time(0) without time zone NOT NULL,
    id_user character varying(36) NOT NULL
);


ALTER TABLE public.log OWNER TO postgres;

--
-- TOC entry 1340 (class 1259 OID 65207)
-- Dependencies: 5
-- Name: ocorrencia; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE ocorrencia (
    id_ocorrencia integer NOT NULL,
    id_func integer NOT NULL,
    id_user character varying(40) NOT NULL,
    data_inicio date NOT NULL,
    data_fim date NOT NULL,
    data_cadastro date NOT NULL,
    tipo_ocorrencia character varying(20) NOT NULL,
    observacao text
);


ALTER TABLE public.ocorrencia OWNER TO postgres;

--
-- TOC entry 1341 (class 1259 OID 65212)
-- Dependencies: 1340 5
-- Name: ocorrencia_id_ocorrencia_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE ocorrencia_id_ocorrencia_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.ocorrencia_id_ocorrencia_seq OWNER TO postgres;

--
-- TOC entry 1770 (class 0 OID 0)
-- Dependencies: 1341
-- Name: ocorrencia_id_ocorrencia_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE ocorrencia_id_ocorrencia_seq OWNED BY ocorrencia.id_ocorrencia;


--
-- TOC entry 1342 (class 1259 OID 65214)
-- Dependencies: 5
-- Name: permissions; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE permissions (
    permission_id character varying(36) NOT NULL,
    permission_action_id character varying(50),
    permission_group_id character varying(36)
);


ALTER TABLE public.permissions OWNER TO postgres;

--
-- TOC entry 1343 (class 1259 OID 65216)
-- Dependencies: 5
-- Name: titulo_prof_id_titulo_prof_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE titulo_prof_id_titulo_prof_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.titulo_prof_id_titulo_prof_seq OWNER TO postgres;

--
-- TOC entry 1344 (class 1259 OID 65218)
-- Dependencies: 1696 5
-- Name: titulo_prof; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE titulo_prof (
    id_titulo_prof bigint DEFAULT nextval('titulo_prof_id_titulo_prof_seq'::regclass) NOT NULL,
    titulo character varying(20) NOT NULL,
    valor_hora_aula money NOT NULL
);


ALTER TABLE public.titulo_prof OWNER TO postgres;

--
-- TOC entry 1345 (class 1259 OID 65221)
-- Dependencies: 5
-- Name: transferencia_id_transferencia_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE transferencia_id_transferencia_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.transferencia_id_transferencia_seq OWNER TO postgres;

--
-- TOC entry 1346 (class 1259 OID 65223)
-- Dependencies: 1697 5
-- Name: transferencia; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE transferencia (
    id_transferencia bigint DEFAULT nextval('transferencia_id_transferencia_seq'::regclass) NOT NULL,
    id_func_origem bigint NOT NULL,
    id_func_destino bigint NOT NULL,
    id_disciplina bigint NOT NULL,
    data_ponto date NOT NULL,
    tempo_total time(0) without time zone NOT NULL
);


ALTER TABLE public.transferencia OWNER TO postgres;

--
-- TOC entry 1347 (class 1259 OID 65226)
-- Dependencies: 5
-- Name: users; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE users (
    user_id character varying(36) NOT NULL,
    user_name character varying(32),
    user_real_name character varying(50),
    user_password character varying(32),
    user_group_id character varying(36)
);


ALTER TABLE public.users OWNER TO postgres;

--
-- TOC entry 1678 (class 2604 OID 65228)
-- Dependencies: 1312 1311
-- Name: id_alteracao_entrada; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE alteracao_entrada ALTER COLUMN id_alteracao_entrada SET DEFAULT nextval('alteracao_entrada_id_alteracao_entrada_seq'::regclass);


--
-- TOC entry 1695 (class 2604 OID 65230)
-- Dependencies: 1341 1340
-- Name: id_ocorrencia; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ocorrencia ALTER COLUMN id_ocorrencia SET DEFAULT nextval('ocorrencia_id_ocorrencia_seq'::regclass);


--
-- TOC entry 1699 (class 2606 OID 65295)
-- Dependencies: 1310 1310
-- Name: actions_new_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY actions
    ADD CONSTRAINT actions_new_pkey PRIMARY KEY (action_id);


--
-- TOC entry 1701 (class 2606 OID 65297)
-- Dependencies: 1311 1311
-- Name: alteracao_entrada_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY alteracao_entrada
    ADD CONSTRAINT alteracao_entrada_pkey PRIMARY KEY (id_alteracao_entrada);


--
-- TOC entry 1703 (class 2606 OID 65301)
-- Dependencies: 1314 1314
-- Name: banco_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY banco
    ADD CONSTRAINT banco_pkey PRIMARY KEY (id_banco);


--
-- TOC entry 1705 (class 2606 OID 65303)
-- Dependencies: 1316 1316
-- Name: configuracao_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY configuracao
    ADD CONSTRAINT configuracao_pkey PRIMARY KEY (id_configuracao);


--
-- TOC entry 1707 (class 2606 OID 65305)
-- Dependencies: 1318 1318
-- Name: curso_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY curso
    ADD CONSTRAINT curso_pkey PRIMARY KEY (id_curso);


--
-- TOC entry 1709 (class 2606 OID 65309)
-- Dependencies: 1320 1320
-- Name: digital_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY digital
    ADD CONSTRAINT digital_pkey PRIMARY KEY (id_digital);


--
-- TOC entry 1711 (class 2606 OID 65311)
-- Dependencies: 1322 1322
-- Name: disciplina_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY disciplina
    ADD CONSTRAINT disciplina_pkey PRIMARY KEY (id_disciplina);


--
-- TOC entry 1713 (class 2606 OID 65313)
-- Dependencies: 1324 1324
-- Name: empresa_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY empresa
    ADD CONSTRAINT empresa_pkey PRIMARY KEY (id_empresa);


--
-- TOC entry 1715 (class 2606 OID 65315)
-- Dependencies: 1326 1326
-- Name: entrada_func_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY entrada_func
    ADD CONSTRAINT entrada_func_pkey PRIMARY KEY (id_entrada_func);


--
-- TOC entry 1717 (class 2606 OID 65317)
-- Dependencies: 1328 1328
-- Name: feriado_data_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY feriado
    ADD CONSTRAINT feriado_data_key UNIQUE (data);


--
-- TOC entry 1719 (class 2606 OID 65319)
-- Dependencies: 1328 1328
-- Name: feriado_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY feriado
    ADD CONSTRAINT feriado_pkey PRIMARY KEY (id_feriado);


--
-- TOC entry 1721 (class 2606 OID 65323)
-- Dependencies: 1330 1330
-- Name: folha_pagamento_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY folha_pagamento
    ADD CONSTRAINT folha_pagamento_pkey PRIMARY KEY (id_folha_pagamento);


--
-- TOC entry 1723 (class 2606 OID 65325)
-- Dependencies: 1332 1332
-- Name: funcionario_cpf_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY funcionario
    ADD CONSTRAINT funcionario_cpf_key UNIQUE (cpf);


--
-- TOC entry 1725 (class 2606 OID 65327)
-- Dependencies: 1332 1332
-- Name: funcionario_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY funcionario
    ADD CONSTRAINT funcionario_pkey PRIMARY KEY (id_funcionario);


--
-- TOC entry 1727 (class 2606 OID 65329)
-- Dependencies: 1333 1333
-- Name: groups_new_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY groups
    ADD CONSTRAINT groups_new_pkey PRIMARY KEY (group_id);


--
-- TOC entry 1729 (class 2606 OID 65331)
-- Dependencies: 1335 1335
-- Name: horario_disc_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY horario_disc
    ADD CONSTRAINT horario_disc_pkey PRIMARY KEY (id_horario_disc);


--
-- TOC entry 1731 (class 2606 OID 65333)
-- Dependencies: 1337 1337
-- Name: horario_func_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY horario_func
    ADD CONSTRAINT horario_func_pkey PRIMARY KEY (id_horario_func);


--
-- TOC entry 1733 (class 2606 OID 65337)
-- Dependencies: 1339 1339
-- Name: log_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY log
    ADD CONSTRAINT log_pkey PRIMARY KEY (id_log);


--
-- TOC entry 1735 (class 2606 OID 65339)
-- Dependencies: 1340 1340
-- Name: ocorrencia_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY ocorrencia
    ADD CONSTRAINT ocorrencia_pkey PRIMARY KEY (id_ocorrencia);


--
-- TOC entry 1737 (class 2606 OID 65341)
-- Dependencies: 1342 1342
-- Name: permissions_new_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY permissions
    ADD CONSTRAINT permissions_new_pkey PRIMARY KEY (permission_id);


--
-- TOC entry 1739 (class 2606 OID 65343)
-- Dependencies: 1344 1344
-- Name: titulo_prof_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY titulo_prof
    ADD CONSTRAINT titulo_prof_pkey PRIMARY KEY (id_titulo_prof);


--
-- TOC entry 1741 (class 2606 OID 65345)
-- Dependencies: 1344 1344
-- Name: titulo_prof_titulo_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY titulo_prof
    ADD CONSTRAINT titulo_prof_titulo_key UNIQUE (titulo);


--
-- TOC entry 1743 (class 2606 OID 65347)
-- Dependencies: 1346 1346
-- Name: transferencia_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY transferencia
    ADD CONSTRAINT transferencia_pkey PRIMARY KEY (id_transferencia);


--
-- TOC entry 1745 (class 2606 OID 65349)
-- Dependencies: 1347 1347
-- Name: users_new_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY users
    ADD CONSTRAINT users_new_pkey PRIMARY KEY (user_id);


--
-- TOC entry 1746 (class 2606 OID 65350)
-- Dependencies: 1311 1326 1714
-- Name: alteracao_entrada_id_entrada_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY alteracao_entrada
    ADD CONSTRAINT alteracao_entrada_id_entrada_fkey FOREIGN KEY (id_entrada) REFERENCES entrada_func(id_entrada_func);


--
-- TOC entry 1747 (class 2606 OID 65355)
-- Dependencies: 1744 1347 1311
-- Name: alteracao_entrada_id_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY alteracao_entrada
    ADD CONSTRAINT alteracao_entrada_id_user_fkey FOREIGN KEY (id_user) REFERENCES users(user_id);


--
-- TOC entry 1748 (class 2606 OID 65365)
-- Dependencies: 1724 1318 1332
-- Name: curso_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY curso
    ADD CONSTRAINT curso_fk FOREIGN KEY (coordenador) REFERENCES funcionario(id_funcionario);


--
-- TOC entry 1749 (class 2606 OID 65375)
-- Dependencies: 1724 1332 1320
-- Name: digital_funcionario_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY digital
    ADD CONSTRAINT digital_funcionario_fk FOREIGN KEY (id_funcionario) REFERENCES funcionario(id_funcionario);


--
-- TOC entry 1750 (class 2606 OID 65380)
-- Dependencies: 1326 1332 1724
-- Name: entrada_func_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY entrada_func
    ADD CONSTRAINT entrada_func_fk FOREIGN KEY (id_func) REFERENCES funcionario(id_funcionario);


--
-- TOC entry 1751 (class 2606 OID 65395)
-- Dependencies: 1332 1724 1330
-- Name: folha_pagamento_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY folha_pagamento
    ADD CONSTRAINT folha_pagamento_fk FOREIGN KEY (id_func) REFERENCES funcionario(id_funcionario);


--
-- TOC entry 1752 (class 2606 OID 65400)
-- Dependencies: 1332 1702 1314
-- Name: funcionario_banco_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY funcionario
    ADD CONSTRAINT funcionario_banco_fk FOREIGN KEY (id_banco) REFERENCES banco(id_banco);


--
-- TOC entry 1753 (class 2606 OID 65779)
-- Dependencies: 1347 1744 1339
-- Name: log_id_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY log
    ADD CONSTRAINT log_id_user_fkey FOREIGN KEY (id_user) REFERENCES users(user_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1754 (class 2606 OID 65410)
-- Dependencies: 1340 1724 1332
-- Name: ocorrencia_id_func_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY ocorrencia
    ADD CONSTRAINT ocorrencia_id_func_fkey FOREIGN KEY (id_func) REFERENCES funcionario(id_funcionario);


--
-- TOC entry 1755 (class 2606 OID 65415)
-- Dependencies: 1744 1347 1340
-- Name: ocorrencia_id_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY ocorrencia
    ADD CONSTRAINT ocorrencia_id_user_fkey FOREIGN KEY (id_user) REFERENCES users(user_id);


--
-- TOC entry 1756 (class 2606 OID 65420)
-- Dependencies: 1310 1698 1342
-- Name: permissions_new_action_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY permissions
    ADD CONSTRAINT permissions_new_action_id_fk FOREIGN KEY (permission_action_id) REFERENCES actions(action_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1757 (class 2606 OID 65425)
-- Dependencies: 1726 1342 1333
-- Name: permissions_new_group_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY permissions
    ADD CONSTRAINT permissions_new_group_id_fk FOREIGN KEY (permission_group_id) REFERENCES groups(group_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1760 (class 2606 OID 65430)
-- Dependencies: 1346 1724 1332
-- Name: transferencia_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY transferencia
    ADD CONSTRAINT transferencia_fk FOREIGN KEY (id_func_origem) REFERENCES funcionario(id_funcionario);


--
-- TOC entry 1758 (class 2606 OID 65435)
-- Dependencies: 1346 1332 1724
-- Name: transferencia_fk1; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY transferencia
    ADD CONSTRAINT transferencia_fk1 FOREIGN KEY (id_func_destino) REFERENCES funcionario(id_funcionario);


--
-- TOC entry 1759 (class 2606 OID 65440)
-- Dependencies: 1346 1322 1710
-- Name: transferencia_fk2; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY transferencia
    ADD CONSTRAINT transferencia_fk2 FOREIGN KEY (id_disciplina) REFERENCES disciplina(id_disciplina);


--
-- TOC entry 1761 (class 2606 OID 65445)
-- Dependencies: 1347 1333 1726
-- Name: users_new_group_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY users
    ADD CONSTRAINT users_new_group_id_fk FOREIGN KEY (user_group_id) REFERENCES groups(group_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1766 (class 0 OID 0)
-- Dependencies: 5
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;


-- Completed on 2008-05-05 01:05:26

--
-- PostgreSQL database dump complete
--

